<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../public/vue.js"></script>
</head>
<body>

<div id="example3">
    <p>Original message: "{{ message }}"</p>
    <p>Computed reversed message: "{{ reversedMessage }}"</p>
    <button v-on:click="changeMsg">change</button>
    <br>
    <p>time:"{{nowTime}}"</p>
</div>

</body>
<script type="text/javascript">
    const vm = new Vue({
        el: '#example3',
        data: {
            message: 'Hello'
        },
        computed: {
            // 计算属性的 getter
            reversedMessage: function () {
                // `this` 指向 vm 实例
                return this.message.split('').reverse().join('')
            },
            nowTime: function () {
                return Date.now()
            }
        },
        methods: {
            changeMsg: function () {
                this.message = this.message.split('').reverse().join('')
            }
        }
    });
</script>
</html>